<!doctype html>
<html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>查询内容</title>
        <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
        <include file="Public:iframe_header"/>
        <style type="text/css">
            *{
                font-size: 95%;
            }
            body{
                text-align: center;
            }
            table{
                width: 90%;
                text-align: center;
                margin: 30px auto;
                border-collapse: separate;
                border-spacing: 0;
                border: 2px #000;
                border: 1px solid #AAAAAA;
                border-radius: 10px;
            }
        table tr th {
            background: #E7E7E7;
        }
        table tr td {
            width: 25%;
        }
           table tr td:first-child,
        table tr td:nth-child(2),
        table tr td:nth-child(3),
        table tr td:last-child{
            border-bottom: 1px solid #E7E7E7;
        }
        table tr:first-child th:first-child {
            border-top-left-radius: 10px;
        }

        table tr:first-child th:last-child {
            border-top-right-radius: 10px;
        }
        table tr:last-child td:first-child {
            border-bottom-left-radius: 10px;
        }

        table tr:last-child td:last-child {
            border-bottom-right-radius: 10px;
        }
        h4{
            margin: 20px auto;
        }
        button{
            text-align: center;
            margin: 20px;
            color: white;
            border-radius: 3px;
            background-color: orange;
            width: 20%;
            height: 30px;
            
        }
        </style>
    </head>

    <body>
        <div class="mui-content" align="center" style="background-color: #fff;">
            <h4>{$company_name}</h4>
            
            <volist name="project_result" id="v">
            <table border="0" cellspacing="0" cellpadding="0">
                <tr >
                    <th colspan="4">{$v.type_name}</th>
                </tr>
                <tr>
                    <td>序号</td>
                    <td>项目名称</td>
                    <td>申请时间/批次</td>
                    <td>补助金额</td>
                </tr>
                <volist name="v.type_array" id="vo">
                    <tr>
                        <td>{$vo.id}</td>
                        <td>{$vo.item_name}</td>
                        <td>{$vo.time_batch}</td>
                        <td>{$vo.subsidy_amount/1000}</td>
                    </tr>
                </volist>
            </table>
            </volist>
        
            <if condition="$is_attention eq 0 || $is_attention eq -1">
                <button onclick="change_class(this)" <if condition="$is_attention eq -1">status="1"<else />status="0"</if>company_id="{$id}">关注</button>
            </if>
            <if condition="$is_attention eq 1">
                <button onclick="change_class(this)"  status="-1" company_id="{$id}">取消关注</button>
            </if>
            
        </div>
    </body>
    <script>
        function change_class(obj){
            var status = $(obj).attr('status');
            var company_id = $(obj).attr('company_id');
            var class_name = $(obj).attr('class');
            var bool = false;

            var formData = new FormData();
            formData.append('status',status);
            formData.append('company_id',company_id);

            $.ajax({
                url:"{:url('Company/follow')}",
                type:'POST',
                data:formData,
                async:false,
                processData:false,
                contentType:false,
                success:function(result){
                    if(result.code == 0){
                        parent.tips(result.msg);
                        bool = true;
                    }
                }

            });

            if(bool){
                return false;
            }


            $(obj).removeClass('btn1');
            $(obj).removeClass('btn3');
            //$(obj).attr('status','');

            if(class_name == 'btn1'){
                $(obj).attr("class","btn3");
                $(obj).text("取消关注");
                $(obj).attr('status','-1');
            }else{
                $(obj).attr("class","btn1");
                $(obj).attr('status','1');
                $(obj).text("+关注");
            }
            
        
        }
    </script>
</html>